/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package consumo.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Carlos Taschetto
 */
@Entity
@Table(name = "leitura", catalog = "consumodb", schema = "")
@NamedQueries({
    @NamedQuery(name = "Leitura.findAll", query = "SELECT l FROM Leitura l"),
    @NamedQuery(name = "Leitura.findById", query = "SELECT l FROM Leitura l WHERE l.id = :id"),
    @NamedQuery(name = "Leitura.findByDataLeituraAnterior", query = "SELECT l FROM Leitura l WHERE l.dataLeituraAnterior = :dataLeituraAnterior"),
    @NamedQuery(name = "Leitura.findByDataLeituraAtual", query = "SELECT l FROM Leitura l WHERE l.dataLeituraAtual = :dataLeituraAtual"),
    @NamedQuery(name = "Leitura.findByKWhtotal", query = "SELECT l FROM Leitura l WHERE l.kWhtotal = :kWhtotal"),
    @NamedQuery(name = "Leitura.findByKVArhtotal", query = "SELECT l FROM Leitura l WHERE l.kVArhtotal = :kVArhtotal"),
    @NamedQuery(name = "Leitura.findByKWmax", query = "SELECT l FROM Leitura l WHERE l.kWmax = :kWmax"),
    @NamedQuery(name = "Leitura.findByFERtotal", query = "SELECT l FROM Leitura l WHERE l.fERtotal = :fERtotal"),
    @NamedQuery(name = "Leitura.findByDMCRmax", query = "SELECT l FROM Leitura l WHERE l.dMCRmax = :dMCRmax"),
    @NamedQuery(name = "Leitura.findByTotal", query = "SELECT l FROM Leitura l WHERE l.total = :total")})
public class Leitura implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "data_leitura_anterior")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataLeituraAnterior;
    @Column(name = "data_leitura_atual")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataLeituraAtual;
    @Column(name = "kWh_total")
    private Integer kWhtotal;
    @Column(name = "kVArh_total")
    private Integer kVArhtotal;
    @Column(name = "kW_max")
    private Integer kWmax;
    @Column(name = "FER_total")
    private Integer fERtotal;
    @Column(name = "DMCR_max")
    private Integer dMCRmax;
    @Column(name = "total", precision = 10, scale = 2)
    private BigDecimal total;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leitura")
    private List<Registradores> registradoresList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leitura")
    private List<ConsumosCobrado> consumosCobradoList;
    @JoinColumn(name = "posto_horario", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private PostoHorario postoHorario;
    @JoinColumn(name = "constantes", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Constantes constantes;
    @JoinColumn(name = "cliente", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Cliente cliente;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "leituraId")
    private List<MmCabecalho> mmCabecalhoList;

    public Leitura() {
    }

    public Leitura(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataLeituraAnterior() {
        return dataLeituraAnterior;
    }

    public void setDataLeituraAnterior(Date dataLeituraAnterior) {
        this.dataLeituraAnterior = dataLeituraAnterior;
    }

    public Date getDataLeituraAtual() {
        return dataLeituraAtual;
    }

    public void setDataLeituraAtual(Date dataLeituraAtual) {
        this.dataLeituraAtual = dataLeituraAtual;
    }

    public Integer getKWhtotal() {
        return kWhtotal;
    }

    public void setKWhtotal(Integer kWhtotal) {
        this.kWhtotal = kWhtotal;
    }

    public Integer getKVArhtotal() {
        return kVArhtotal;
    }

    public void setKVArhtotal(Integer kVArhtotal) {
        this.kVArhtotal = kVArhtotal;
    }

    public Integer getKWmax() {
        return kWmax;
    }

    public void setKWmax(Integer kWmax) {
        this.kWmax = kWmax;
    }

    public Integer getFERtotal() {
        return fERtotal;
    }

    public void setFERtotal(Integer fERtotal) {
        this.fERtotal = fERtotal;
    }

    public Integer getDMCRmax() {
        return dMCRmax;
    }

    public void setDMCRmax(Integer dMCRmax) {
        this.dMCRmax = dMCRmax;
    }

    public BigDecimal getTotal() {
        return total;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public List<Registradores> getRegistradoresList() {
        return registradoresList;
    }

    public void setRegistradoresList(List<Registradores> registradoresList) {
        this.registradoresList = registradoresList;
    }

    public List<ConsumosCobrado> getConsumosCobradoList() {
        return consumosCobradoList;
    }

    public void setConsumosCobradoList(List<ConsumosCobrado> consumosCobradoList) {
        this.consumosCobradoList = consumosCobradoList;
    }

    public PostoHorario getPostoHorario() {
        return postoHorario;
    }

    public void setPostoHorario(PostoHorario postoHorario) {
        this.postoHorario = postoHorario;
    }

    public Constantes getConstantes() {
        return constantes;
    }

    public void setConstantes(Constantes constantes) {
        this.constantes = constantes;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public List<MmCabecalho> getMmCabecalhoList() {
        return mmCabecalhoList;
    }

    public void setMmCabecalhoList(List<MmCabecalho> mmCabecalhoList) {
        this.mmCabecalhoList = mmCabecalhoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Leitura)) {
            return false;
        }
        Leitura other = (Leitura) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "consumo.persistence.Leitura[id=" + id + "]";
    }

}
